#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

const int N = 100010;

int son[N * 31][2], a[N]; 
int n, idx;

void add(int x)
{
    int p = 0; 
    for(int i = 30;i >= 0; i -- )
    {
        int u = x >> i & 1;   
        if(!son[p][u]) son[p][u] = ++ idx;
        p = son[p][u]; 
    }
}

int query(int x)
{
    int p = 0, ans = 0;
    for(int i = 30; i >= 0; i -- ){                              
        int u = x >> i & 1;
        if(son[p][!u]){  
          p = son[p][!u];
          ans = ans * 2 + 1;
        }                                       
        else{
           p = son[p][u];
           ans *= 2;
        }
    }
    return ans;
}

int main()
{
    scanf("%d", &n);
    int m = 0;
    for(int i = 0; i < n; i ++ ){
        scanf("%d", &a[i]);
        add(a[i]);
        m = max(m,query(a[i]));
    }
    cout << m << endl;
}